package cn.sanshuilin.kst.system.provider.write.dao;

import cn.sanshuilin.kst.system.provider.bean.Location;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author greenlee
 * @version v1.0
 * @create 创建时间: 2017-11-29 21:03
 * Copyright 2017  by 三水林科技有限公司
 **/
public interface LocationDao extends JpaRepository<Location, String> {
    Location findById(String id);

    @Transactional
    @Modifying
    @Query(value = "DELETE FROM Location WHERE ID =:ID", nativeQuery = true)
    int removeById(@Param("ID") String ID);

    @Transactional
    @Modifying
    @Query(value = "UPDATE location SET Address =:address,Lat=:lat,Lng=:lng WHERE ID=:ID", nativeQuery = true)
    int updateLocation(@Param("ID") String ID, @Param("address") String address, @Param("lat") Double lat, @Param("lng") Double lng);
}
